<?php

include '../db.php';
$connect = pg_connect($connectionString);
if (!$connect) {
    echo "connect : A connection to the server could not be established!";
    return false;
}

$params = array();
array_push($params, pg_escape_string($_POST["move_date"]));
array_push($params, pg_escape_string($_POST["type"]));
array_push($params, pg_escape_string($_POST["price"]));
array_push($params, pg_escape_string($_POST["quantity"]));
array_push($params, pg_escape_string($_POST["total"]));
array_push($params, pg_escape_string($_POST["product_id"]));

$stmt = pg_prepare($connect, "create_move", "INSERT INTO move(move_date,type,price,quantity,total,product_id) VALUES ($1,$2,$3,$4,$5,$6);");
$result = pg_execute($connect, "create_move", $params);

if (!$result) {
    die("Error in SQL query: " . pg_last_error());
}
pg_free_result($result);
pg_close($connect);


